# -*- coding: utf-8 -*-
# @Time : 2021/9/12 17:47
# @Author : hello
# @Email : xxx@gmail.com
# @File : addcusbases_page.py
# @Project : crm

from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from page.base_page import BasePage
from utils.util import HOST

class CusBases(BasePage):
    # def __init__(self,driver):
    #     self.driver=driver

    #属性
    url="{}/index.php?m=customer&a=index".format(HOST)
    fzr = (By.ID, 'owner_name')
    khmc = (By.ID, 'name')
    khhy = (By.ID, 'industry')  # 单选
    khxxly = (By.ID, 'origin')  # --下拉框
    companyxz = (By.ID, 'ownership2')  # 单选
    # yb = (By.ID, 'zip_code')
    yb=(By.XPATH,'//*[@id="zip_code"]')
    yearmy = (By.ID, 'annual_revenue')  # --下拉框
    pf = (By.ID, 'rating1')  # 单选
    adress_x = (By.NAME, "address['state']")
    adress_s = (By.NAME, "address['city']")
    adress_q = (By.NAME, "address['area']")
    jd = (By.NAME, "address['street']")
    # 首要联系人
    syname = (By.NAME, 'con_name')
    sych = (By.NAME, 'saltname')
    syyx = (By.NAME, 'con_email')
    syzw = (By.NAME, 'con_post')
    syqq = (By.NAME, 'con_qq')
    syphone = (By.NAME, 'con_telephone')
    sybz = (By.NAME, 'con_description')
    fzyg = (By.ID, 'no_of_employees')  # 下拉框
    fzbz = (By.ID, 'description')
    bc = (By.CSS_SELECTOR, 'input[value="保存"]')
    clickadd = (By.CSS_SELECTOR, 'body > div.container > div.row > div:nth-child(1) > div > a')
    #放入客户池
    khc = (By.CSS_SELECTOR, 'input[value="放入客户池"]')

    #方法
    #点击添加客户
    def click_cus(self):
        self.driver.find_element(*self.clickadd).click()

    def input_fzr(self,fzrs):
        """输入负责人"""
        fzr=self.driver.find_element(*self.fzr)
        fzr.clear()
        fzr.send_keys(fzrs)
    def input_khmc(self,khmcs):
        """输入客户名称"""
        self.driver.find_element(*self.khmc).send_keys(khmcs)
    def input_khhy(self):
        """单选客户行业"""
        self.driver.find_element(*self.khhy).click()
    def input_khxxly(self,kly):
        """选择客户信息来源"""
        khxx_locator = self.driver.find_element(*self.khxxly)
        Select(khxx_locator).select_by_visible_text(kly)
    def input_companyxz(self):
        """单选公司性质"""
        self.driver.find_element(*self.companyxz).click()
    def input_yb(self, ybs):
        """输入邮编"""
        self.driver.find_element(*self.yb).send_keys(ybs)
    def input_yearmy(self, ym):
        """选择年营业额"""
        yearmy_locator = self.driver.find_element(*self.yearmy)
        Select(yearmy_locator).select_by_visible_text(ym)
    def input_pf(self):
        """选择评分"""
        self.driver.find_element(*self.pf).click()
    def input_xadress(self, xadress):
        """选择省"""
        ele = self.driver.find_element(*self.adress_x)
        ele1 = Select(ele)
        ele1.select_by_visible_text(xadress)

    def input_sadress(self, sadress):
        """选择市"""
        ele = self.driver.find_element(*self.adress_s)
        ele2 = Select(ele)
        ele2.select_by_visible_text(sadress)

    def input_qadress(self, qadress):
        """选择区"""
        ele = self.driver.find_element(*self.adress_q)
        ele3 = Select(ele)
        ele3.select_by_visible_text(qadress)

    def input_jdadress(self, jdadress):
        """输入街道信息"""
        self.driver.find_element(*self.jd).send_keys(jdadress)
#首要联系人
    def input_sname(self, name):
        """输入姓名"""
        self.driver.find_element(*self.syname).send_keys(name)

    def input_sych(self, sychs):
        """输入称呼"""
        self.driver.find_element(*self.sych).send_keys(sychs)

    def input_syyx(self, syyxs):
        """输入邮箱"""
        self.driver.find_element(*self.syyx).send_keys(syyxs)

    def input_syzws(self, syzws):
        """输入职位"""
        self.driver.find_element(*self.syzw).send_keys(syzws)

    def input_syqq(self, syqqs):
        """输入qq"""
        self.driver.find_element(*self.syqq).send_keys(syqqs)

    def input_syphone(self, syphones):
        """输入手机"""
        self.driver.find_element(*self.syphone).send_keys(syphones)
    def input_sybz(self, sybzs):
        """输入首要备注"""
        self.driver.find_element(*self.sybz).send_keys(sybzs)
    def input_syygs(self, syygs):
        """选择员工"""
        yg_locator =self.driver.find_element(*self.fzyg)
        Select(yg_locator).select_by_visible_text(syygs)
    def input_fzbz(self, fzbzs):
        """输入附加备注"""
        self.driver.find_element(*self.fzbz).send_keys(fzbzs)
    def click_bc(self):
        """保存"""
        self.driver.find_element(*self.bc).click()

    def putkhc(self):
        """放入客户池"""
        self.driver.find_element(*self.khc).click()



